<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
</head>
<body>

<div id="listValues"></div>

<input type='button' value='批量生成' id='createCode'/>
<input type="button" id="ss" value="跳转">

</body>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $("#ss").click(function () {
        $.ajax({
            url:'/index',
            type:'get',
            async:false,
            data:'',
            dataType:'json',
            success:function (data) {
                sessionStorage.setItem("tableData",JSON.stringify(data.tables));
//                console.log("进来=="+JSON.stringify(sessionStorage.getItem("tableData")));
                data=data.tables;
                //table_name tableName, engine, table_comment tableComment, create_time createTime
               var s1="<form action='/batchCode' method='post' id='form11'><table border='1' cellpadding='1' id='tableCode'>\n" +
                   "        <thead>\n" +
                   "            <th></th>\n" +
                   "            <th>表名</th>\n" +
                   "            <th>表描述</th>\n" +
                   "            <th>创建时间</th>\n" +
                   "            <th>engine</th>\n" +
                   "        </thead>\n" +
                   "        <tbody>\n" ;
               var s2="";
               for(var i=0;i<data.length;i++){
                   s2+="<tr><td><input type='checkbox' id='"+data[i].id+"'/></td><td>"+data[i].tableName+"</td><td>"+data[i].tableComment+"</td><td>"+data[i].createTime+"</td>"+
                       "<td>"+data[i].engine+"</td></tr>";
               }
               var s3="</tbody>\n" +
                   "    </table><input type='hidden' value='"+sessionStorage.getItem("tableData")+"' name='downData'><input type='submit' value='提交' onclick='sss();'></form>";
                $("#listValues").append(s1+s2+s3);
            }
        });
    });

    function sss(){
        var form=document.getElementById("form11");
        form.submit();
    }

    $("#createCode").click(function () {
        window.location.href="/edit";
//        console.log("进来了"+sessionStorage.getItem("tableData"));
//        var url="/edit";
//        $.ajax({
//            url:url,
//            data:{} ,
//            async:false,
//            type:'get',
//            dataType:'json',
//            success:function (data) {
//                //<a href="/edit">批量生成</a>
//
//            }
//        });
    })

</script>
</html>